﻿from Tkinter import *
import ttk,win32gui

def overlayiniciogame(root,teamonestats,teamtwostats):
        # Funcion que genera overlay de todos los jugadores sobre pantalla de carga.
        # No genera boton de cerrar overlay
        # return [ancho,alto,overlaywindow,overlaywindow2]
        
    try:
        #Obtengo tamaño pantalla lol
        indexventana= win32gui.FindWindow(None,'League of Legends (TM) Client')
        win32gui.SetForegroundWindow(indexventana) 
        esquinas=win32gui.GetWindowRect(indexventana)
        ##  LO SIGUIENTE DEBE ESTAR COMENTADO
##        esquinas=(0, 0, 1366, 768)
        
       ##  Calculo donde deben estar las ventanas segun donde este ventana lol
        alto=esquinas[3]-esquinas[1]
        ancho=esquinas[2]-esquinas[0]
        pos1=[ancho*0.14,alto*0.2] #horizontal,vertical
        pos2=[ancho*0.14,alto*0.71]
        separacion=0.147*ancho
        tamh=ancho*0.13
        tamv=alto*0.16

        fuente='Verdana'
        tamano='8' 

##      EQUIPO 1
        overlaywindow=[0]*5
        for i in range(5):
             
                overlaywindow[i] = Toplevel(root)
                overlaywindow[i].configure(background = 'black')
                overlaywindow[i].wm_attributes("-topmost", 1)
                overlaywindow[i].geometry('{2}x{3}+{0}+{1}'.format(int(round(pos1[0]+i*separacion)),int(round(pos1[1])),int(round(tamh)),int(round(tamv))))
                overlaywindow[i].overrideredirect(1)
                
                ttk.Label(overlaywindow[i], text='{0}'.format(teamonestats[i]["campeon"]),font="{0} {1}".format(fuente,tamano),foreground="white", background="black").grid(column=1,columnspan=2, row=1, sticky=())

                ttk.Label(overlaywindow[i], text='S3',font="{0} {1}".format(fuente,tamano),foreground="white", background="black").grid(column=1,rowspan=2, row=2, sticky=())
                ttk.Label(overlaywindow[i], text='S2',font="{0} {1}".format(fuente,tamano),foreground="white", background="black").grid(column=1,rowspan=2, row=4, sticky=())
##   S3
                if teamonestats[i]["stats"]["statscampeon"]["victorias"]>=50:
                        color="dark green"
                else:
                        color="red"
                      
                ttk.Label(overlaywindow[i], text='P: {0}     V: {1}%'.format(teamonestats[i]["stats"]["statscampeon"]["jugadas"],teamonestats[i]["stats"]["statscampeon"]["victorias"]),font="{0} {1}".format(fuente,tamano),foreground=color, background="black").grid(column=2, row=2, sticky=())
                ttk.Label(overlaywindow[i], text='KDA: {0} / {1} / {2}'.format(teamonestats[i]["stats"]["statscampeon"]["avgkills"],teamonestats[i]["stats"]["statscampeon"]["avgdeaths"],teamonestats[i]["stats"]["statscampeon"]["avgassists"]),font="{0} {1}".format(fuente,tamano),foreground=color, background="black").grid(column=2, row=3, sticky=())
##  S2         
                if teamonestats[i]["stats"]["statscampeonseason2"]["victorias"]>=50:
                        color="dark green"
                else:
                        color="red"
                      
                ttk.Label(overlaywindow[i], text='P: {0}     V: {1}%'.format(teamonestats[i]["stats"]["statscampeonseason2"]["jugadas"],teamonestats[i]["stats"]["statscampeonseason2"]["victorias"]),font="{0} {1}".format(fuente,tamano),foreground=color, background="black").grid(column=2, row=4, sticky=())
                ttk.Label(overlaywindow[i], text='KDA: {0} / {1} / {2}'.format(teamonestats[i]["stats"]["statscampeonseason2"]["avgkills"],teamonestats[i]["stats"]["statscampeonseason2"]["avgdeaths"],teamonestats[i]["stats"]["statscampeonseason2"]["avgassists"]),font="{0} {1}".format(fuente,tamano),foreground=color, background="black").grid(column=2, row=5, sticky=())
                      
                ttk.Label(overlaywindow[i], text='ELO S3: {0}     ELO S2: {1}'.format(teamonestats[i]["stats"]["elosolo5v5"],teamonestats[i]["stats"]['elosolo5v5season2']),font="{0} {1}".format(fuente,tamano),background="black",foreground="white").grid(column=1, columnspan=2, row=6, sticky=())
                ttk.Label(overlaywindow[i], text='{0}'.format(teamonestats[i]["name"]),font="{0} {1}".format(fuente,tamano),foreground="white", background="black").grid(column=1,columnspan=2, row=7, sticky=())                               

                for child in overlaywindow[i].winfo_children(): child.grid_configure(padx=0, pady=0)

##      EQUIPO 2
        overlaywindow2=[0]*5
        for i in range(5):
             
                overlaywindow2[i] = Toplevel(root)
                overlaywindow2[i].configure(background = 'black')
                overlaywindow2[i].wm_attributes("-topmost", 1)
                overlaywindow2[i].geometry('{2}x{3}+{0}+{1}'.format(int(round(pos2[0]+i*separacion)),int(round(pos2[1])),int(round(tamh)),int(round(tamv))))
                overlaywindow2[i].overrideredirect(1)

                ttk.Label(overlaywindow2[i], text='{0}'.format(teamtwostats[i]["campeon"]),font="{0} {1}".format(fuente,tamano),foreground="white", background="black").grid(column=1,columnspan=2, row=1, sticky=())

                ttk.Label(overlaywindow2[i], text='S3',font="{0} {1}".format(fuente,tamano),foreground="white", background="black").grid(column=1,rowspan=2, row=2, sticky=())
                ttk.Label(overlaywindow2[i], text='S2',font="{0} {1}".format(fuente,tamano),foreground="white", background="black").grid(column=1,rowspan=2, row=4, sticky=())
##   S3
                if teamtwostats[i]["stats"]["statscampeon"]["victorias"]>=50:
                        color="dark green"
                else:
                        color="red"
                      
                ttk.Label(overlaywindow2[i], text='P: {0}     V: {1}%'.format(teamtwostats[i]["stats"]["statscampeon"]["jugadas"],teamtwostats[i]["stats"]["statscampeon"]["victorias"]),font="{0} {1}".format(fuente,tamano),foreground=color, background="black").grid(column=2, row=2, sticky=())
                ttk.Label(overlaywindow2[i], text='KDA: {0} / {1} / {2}'.format(teamtwostats[i]["stats"]["statscampeon"]["avgkills"],teamtwostats[i]["stats"]["statscampeon"]["avgdeaths"],teamtwostats[i]["stats"]["statscampeon"]["avgassists"]),font="{0} {1}".format(fuente,tamano),foreground=color, background="black").grid(column=2, row=3, sticky=())
##  S2         
                if teamtwostats[i]["stats"]["statscampeonseason2"]["victorias"]>=50:
                        color="dark green"
                else:
                        color="red"
                      
                ttk.Label(overlaywindow2[i], text='P: {0}     V: {1}%'.format(teamtwostats[i]["stats"]["statscampeonseason2"]["jugadas"],teamtwostats[i]["stats"]["statscampeonseason2"]["victorias"]),font="{0} {1}".format(fuente,tamano),foreground=color, background="black").grid(column=2, row=4, sticky=())
                ttk.Label(overlaywindow2[i], text='KDA: {0} / {1} / {2}'.format(teamtwostats[i]["stats"]["statscampeonseason2"]["avgkills"],teamtwostats[i]["stats"]["statscampeonseason2"]["avgdeaths"],teamtwostats[i]["stats"]["statscampeonseason2"]["avgassists"]),font="{0} {1}".format(fuente,tamano),foreground=color, background="black").grid(column=2, row=5, sticky=())
                      
                ttk.Label(overlaywindow2[i], text='ELO S3: {0}     ELO S2: {1}'.format(teamtwostats[i]["stats"]["elosolo5v5"],teamtwostats[i]["stats"]['elosolo5v5season2']),font="{0} {1}".format(fuente,tamano),background="black",foreground="white").grid(column=1, columnspan=2, row=6, sticky=())
                ttk.Label(overlaywindow2[i], text='{0}'.format(teamtwostats[i]["name"]),font="{0} {1}".format(fuente,tamano),foreground="white", background="black").grid(column=1,columnspan=2, row=7, sticky=())
               
                for child in overlaywindow2[i].winfo_children(): child.grid_configure(padx=0, pady=0)
  
        return [ancho,alto,overlaywindow,overlaywindow2]

    except:
        textoinfo.set(dic[01])
        pass
